Imports MbUnit.Framework
Imports QS = AppliedRecognition.Speech.QuickSwitch

<TestFixture("Test Speech Commands w/o speech")> _
Public Class NoSpeechCommandsTest


    Dim d As QS.CommandDispatch
    Dim u As New Util
    Private ShowTasksFlag As Boolean = False
    Private ShowResizeFlag As Boolean = False

    <Test()> _
    Sub ShowTasks()
        AddHandler d.AfterShowTasks, AddressOf Me.AfterShowTasks
        d.Show()
        d.ShowTasks()
        System.Windows.Forms.Application.Run(QS.ShowTasksForm.Instance)
        Assert.IsTrue(ShowTasksFlag, "ShowTasksFlag is false")

    End Sub

    Sub AfterShowTasks(ByVal sender As Object, ByVal ea As EventArgs)
        Assert.AreSame(sender, d)
        ShowTasksFlag = True
    End Sub


    <Test()> _
Sub ShowResize()
        AddHandler d.AfterResizePreview, AddressOf Me.AfterResizePreview
        d.Show()
        d.ResizePreview()
        System.Windows.Forms.Application.Run(QS.ResizePreviewForm.Instance)
        Assert.IsTrue(ShowResizeFlag, "Showresizeflag is false")
    End Sub
    Sub AfterResizePreview(ByVal sender As Object, ByVal ea As EventArgs)
        Assert.AreSame(sender, d)
        ShowResizeFlag = True
    End Sub



    <TestFixtureTearDown()> _
    Sub FTearDown()
        Dim c As New QS.QuickSwitchConfig
        Dim f As String = IO.Path.Combine(c.DataPath, "QuickSwitch.ini")
        If IO.File.Exists(f) Then
            IO.File.Delete(f)
        End If
        If QS.CommandDispatch.Exists Then
            QS.CommandDispatch.DefaultInstance.Close()
            d = Nothing
        End If
        f = IO.Path.Combine(Environment.CurrentDirectory, "runtime.lic")
        If IO.File.Exists(f) Then
            IO.File.Delete(f)
        End If
    End Sub
    <TestFixtureSetUp()> _
    Sub FSetUp()
        u.WriteConfigFileToDir("DevComplete.lic", IO.Path.Combine(Environment.CurrentDirectory, "runtime.lic"))
        d = New QS.CommandDispatch
        QS.My.MySettings.Default.SpeechEnabledAtStartup = False
        QS.My.MySettings.Default.DisplayTimout = 50
    End Sub



End Class
